package com.ruoyi.truth.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.truth.domain.QuanInfo;
import com.ruoyi.truth.service.IQuanInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业经营数据Controller
 * 
 * @author ruoyi
 * @date 2023-07-05
 */
@RestController
@RequestMapping("/truth/quanInfo")
public class QuanInfoController extends BaseController
{
    @Autowired
    private IQuanInfoService quanInfoService;

    /**
     * 查询企业经营数据列表
     */
    @PreAuthorize("@ss.hasPermi('truth:quanInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(QuanInfo quanInfo)
    {
        startPage();
        List<QuanInfo> list = quanInfoService.selectQuanInfoList(quanInfo);
        return getDataTable(list);
    }

    /**
     * 导出企业经营数据列表
     */
    @PreAuthorize("@ss.hasPermi('truth:quanInfo:export')")
    @Log(title = "企业经营数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QuanInfo quanInfo)
    {
        List<QuanInfo> list = quanInfoService.selectQuanInfoList(quanInfo);
        ExcelUtil<QuanInfo> util = new ExcelUtil<QuanInfo>(QuanInfo.class);
        util.exportExcel(response, list, "企业经营数据数据");
    }

    /**
     * 获取企业经营数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('truth:quanInfo:query')")
    @GetMapping(value = "/{quaninfoId}")
    public AjaxResult getInfo(@PathVariable("quaninfoId") Long quaninfoId)
    {
        return success(quanInfoService.selectQuanInfoByQuaninfoId(quaninfoId));
    }

    /**
     * 新增企业经营数据
     */
    @PreAuthorize("@ss.hasPermi('truth:quanInfo:add')")
    @Log(title = "企业经营数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QuanInfo quanInfo)
    {
        return toAjax(quanInfoService.insertQuanInfo(quanInfo));
    }

    /**
     * 修改企业经营数据
     */
    @PreAuthorize("@ss.hasPermi('truth:quanInfo:edit')")
    @Log(title = "企业经营数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QuanInfo quanInfo)
    {
        return toAjax(quanInfoService.updateQuanInfo(quanInfo));
    }

    /**
     * 删除企业经营数据
     */
    @PreAuthorize("@ss.hasPermi('truth:quanInfo:remove')")
    @Log(title = "企业经营数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{quaninfoIds}")
    public AjaxResult remove(@PathVariable Long[] quaninfoIds)
    {
        return toAjax(quanInfoService.deleteQuanInfoByQuaninfoIds(quaninfoIds));
    }
}
